package com.wiz.weixin.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.wiz.weixin.mapper.PrPriceMapper;
import com.wiz.weixin.service.PrPriceService;
import com.wiz.weixin.to.PrPriceTO;

@Service("prPriceService")
public class PrPriceServiceImpl implements PrPriceService {
	
	@Resource
	private PrPriceMapper prPriceMapper;

	@Override
	public Map<String,List<PrPriceTO>> listPrPrice(List<String> list) {
		Map<String,List<PrPriceTO>> map = new HashMap<String, List<PrPriceTO>>();
		List<PrPriceTO> prPriceList = null;
		Map<Object, Object> parammap = new HashMap<Object, Object>();
		parammap.put("list", list);
		List<PrPriceTO> result = prPriceMapper.getPrPriceListByHqIds(parammap);
		for (PrPriceTO prPriceTO : result) {
			String key = prPriceTO.getStationId()+":"+prPriceTO.getStationName();
			if(map.containsKey(key)){
				prPriceList = map.get(key);
			}else{
				prPriceList = new ArrayList<PrPriceTO>();
			}
			prPriceList.add(prPriceTO);
			map.put(key, prPriceList);
		}
		return map;
	}
	
	@Override
	public PrPriceTO getPrPricebyQrId(String qrId) {
		return prPriceMapper.getPrPricebyQrId(qrId);
	}

}
